﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using TouchUI;
using GoogleVoice;

namespace GVVVM
{
    public class MainDialogListItem : ScrollListItem
    {
        private int row;
        private Bitmap image;
        public VoiceMail thisVoicemail;

        public MainDialogListItem(int row, int screenFactor, VoiceMail voiceMail)
        {
            this.row = row;
            this.ScreenFactor = screenFactor;
            thisVoicemail = voiceMail;
            //this.image = Common.Instance.LoadBitmap("imagesmall", 40, 40);
        }
        
        public override void Paint(Graphics g)
        {
            Brush fontBrush;
            Pen pen;
            if (!Selected)
            {
                fontBrush = Common.Instance.FontBrush;
                pen = Common.Instance.Pen2;
            }
            else
            {
                fontBrush = Common.Instance.HighTextBrush;
                pen = Common.Instance.HighTextPen2;
            }
            

            string s = Common.Instance.TruncateOneLine(g, thisVoicemail.DisplayNumber, Common.Instance.Font, Rectangle.Width - (10 - 40 - 16) * ScreenFactor);
            Size size = g.MeasureString(s, Common.Instance.Font).ToSize();
            g.DrawString(s, Common.Instance.Font, fontBrush, Rectangle.Left + (10 + 40) * ScreenFactor, Rectangle.Top + 8 * ScreenFactor);
            s = Common.Instance.TruncateOneLine(g, thisVoicemail.DisplayStartDateTime.ToString(), Common.Instance.SubFont, Rectangle.Width - 10 - 40 - 16 * ScreenFactor);
            g.DrawString(s, Common.Instance.SubFont, fontBrush, Rectangle.Left + (10 + 40) * ScreenFactor,
                Rectangle.Top + size.Height + (8 + 2) * ScreenFactor);

            int x1 = Rectangle.Left + Rectangle.Width - 12 * ScreenFactor;
            int x2 = x1 + 4 * ScreenFactor;
            int y2 = Rectangle.Top + Rectangle.Height / 2;
            int y1 = y2 - 4 * ScreenFactor;
            int y3 = y2 + 4 * ScreenFactor;
            g.DrawLines(pen, new Point[] { new Point(x1, y1), new Point(x2, y2), new Point(x1, y3) });
        }
    }
}
